const fs = require('fs');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const entryDir = path.resolve(__dirname, '../src/pages/')
const files = fs.readdirSync(entryDir)
const entry = {}, pages = [];

files.forEach((filename, index) => {
    let page = new HtmlWebpackPlugin({
        filename: filename.concat('.html'),
        favicon: path.resolve(__dirname, '../src/assets/favicon.ico'),
        inject: true,
        template: `./src/pages/${filename}/${filename}.html`,
        chunks: [filename, 'vendor']
    });
    entry[filename] = `${entryDir}/${filename}/${filename}.ts`
    pages.push(page)
})

module.exports = {
    entry,
    pages
}